import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(primaryColor: Colors.green),
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  const Home({Key? key}) : super(key: key);

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    //设置尺寸（填写设计中设备的屏幕尺寸）如果设计基于360dp * 690dp的屏幕
    ScreenUtil.init(
        BoxConstraints(
            maxWidth: MediaQuery.of(context).size.width,
            maxHeight: MediaQuery.of(context).size.height),
        designSize: Size(360, 720),
        orientation: Orientation.portrait);
    return Scaffold(
      body: CustomScrollView(
            scrollBehavior:MaterialScrollBehavior() ,
            slivers: [
              SliverAppBar(
                floating: false,
                pinned: true,
                snap: false,
                centerTitle: false,
                expandedHeight: 280,
                flexibleSpace: FlexibleSpaceBar(
                  centerTitle: true,
                  title: Text("123456"),
                  background: Image.network("https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1719187876,1243668359&fm=26&gp=0.jpg",fit:BoxFit.fill ,),
                ),
              ),
              SliverList(delegate: SliverChildBuilderDelegate((BuildContext context, int index){
                 return ListTile(
                   leading:
                   Image.asset("res/drawable/drawable-xxhdpi/ic_app_logo.png"),
                   title: Text("我是标题${index}"),
                   subtitle: Text("我是标题2"),
                   trailing: Image.asset(
                       "res/drawable/drawable-xxhdpi/ic_arrow_right_gray_medium.png"),
                 );;
              }))
            ],
      ),);
  }
}
